package com.maxie.proxy;

import com.maxie.proxy.service.PersonService;
import com.maxie.proxy.service.PersonServiceImpl;

import java.lang.reflect.Proxy;

/**
 * 代理
 */
public class PersonServiceProxy {

    public static PersonService proxy() {
        PersonService personService = new PersonServiceImpl();
        return (PersonService) Proxy.newProxyInstance(personService.getClass().getClassLoader(),
//                personService.getClass().getInterfaces(),
                new Class[]{PersonService.class}, // 显式指定接口
                new PersonInvocationHandle(personService));
    }
}
